
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 12/11/2014 22:19:50
-- Generated from EDMX file: \\vmware-host\Shared Folders\Documents\Visual Studio 2013\Projects\LandandSurvey\LandandSurvey\LandSModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [landsdb];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[PlanItems]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PlanItems];
GO
IF OBJECT_ID(N'[dbo].[Plan1186]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Plan1186];
GO
IF OBJECT_ID(N'[dbo].[AppUsers]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AppUsers];
GO
IF OBJECT_ID(N'[dbo].[AboutContents]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AboutContents];
GO
IF OBJECT_ID(N'[dbo].[OtherPlans]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OtherPlans];
GO
IF OBJECT_ID(N'[dbo].[Counties]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Counties];
GO
IF OBJECT_ID(N'[dbo].[Surveyors]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Surveyors];
GO
IF OBJECT_ID(N'[dbo].[BookPlans]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BookPlans];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'PlanItems'
CREATE TABLE [dbo].[PlanItems] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PlanReference] nvarchar(max)  NOT NULL,
    [Owner] nvarchar(max)  NOT NULL,
    [Location] nvarchar(max)  NOT NULL,
    [Acreage] nvarchar(max)  NOT NULL,
    [Surveyor] nvarchar(max)  NOT NULL,
    [SheetNumber] nvarchar(max)  NOT NULL,
    [DateSigned] nvarchar(max)  NOT NULL,
    [FileName] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Plan1186'
CREATE TABLE [dbo].[Plan1186] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [ParcelOwner] nvarchar(max)  NOT NULL,
    [Locality] nvarchar(max)  NOT NULL,
    [AreaAcre] nvarchar(max)  NOT NULL,
    [AreaSF] nvarchar(max)  NOT NULL,
    [AreaSM] nvarchar(max)  NOT NULL,
    [AreaHA] nvarchar(max)  NOT NULL,
    [BookNo] nvarchar(max)  NOT NULL,
    [Folio] nvarchar(max)  NOT NULL,
    [WardSheetOld] nvarchar(max)  NOT NULL,
    [WardSheetNew] nvarchar(max)  NOT NULL,
    [WardSheetNewSection] nvarchar(max)  NOT NULL,
    [FileName] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'AppUsers'
CREATE TABLE [dbo].[AppUsers] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserName] nvarchar(max)  NOT NULL,
    [UploadFiles] bit  NOT NULL,
    [EditAbout] bit  NOT NULL,
    [Password] nvarchar(max)  NOT NULL,
    [IsAdmin] bit  NOT NULL
);
GO

-- Creating table 'AboutContents'
CREATE TABLE [dbo].[AboutContents] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Content] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'OtherPlans'
CREATE TABLE [dbo].[OtherPlans] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PlanReference] nvarchar(max)  NULL,
    [Name] nvarchar(max)  NULL,
    [Acreage] nvarchar(max)  NULL,
    [Ward] nvarchar(max)  NULL,
    [WardRefCassini] nvarchar(max)  NULL,
    [WardRefUTM] nvarchar(max)  NULL,
    [Surveyor] nvarchar(max)  NULL,
    [DateSignedSurveyor] nvarchar(max)  NULL,
    [DateSignedDirector] nvarchar(max)  NULL,
    [SurveyOrderNumber] nvarchar(max)  NULL,
    [RPOVolume] nvarchar(max)  NULL,
    [RPOFolio] nvarchar(max)  NULL,
    [CTVolume] nvarchar(max)  NULL,
    [CTFolio] nvarchar(max)  NULL,
    [LandSNumber] nvarchar(max)  NULL,
    [Remarks] nvarchar(max)  NULL,
    [FileName] nvarchar(max)  NULL,
    [DeedNumber] nvarchar(max)  NULL
);
GO

-- Creating table 'Counties'
CREATE TABLE [dbo].[Counties] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Ward] nvarchar(max)  NOT NULL,
    [Status] bit  NOT NULL
);
GO

-- Creating table 'Surveyors'
CREATE TABLE [dbo].[Surveyors] (
    [Id] int  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Status] bit  NOT NULL
);
GO

-- Creating table 'BookPlans'
CREATE TABLE [dbo].[BookPlans] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [BookNo] nvarchar(max)  NULL,
    [Name] nvarchar(max)  NULL,
    [Acreage] nvarchar(max)  NULL,
    [Ward] nvarchar(max)  NULL,
    [WardRefCassini] nvarchar(max)  NULL,
    [WardRefUTM] nvarchar(max)  NULL,
    [Surveyor] nvarchar(max)  NULL,
    [DateSignedSurveyor] nvarchar(max)  NULL,
    [DateSignedDirector] nvarchar(max)  NULL,
    [SurveyOrderNumber] nvarchar(max)  NULL,
    [RPOVolume] nvarchar(max)  NULL,
    [RPOFolio] nvarchar(max)  NULL,
    [CTVolume] nvarchar(max)  NULL,
    [CTFolio] nvarchar(max)  NULL,
    [LandSNumber] nvarchar(max)  NULL,
    [Remarks] nvarchar(max)  NULL,
    [FileName] nvarchar(max)  NULL,
    [DeedNumber] nvarchar(max)  NULL,
    [Folio] nvarchar(max)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'PlanItems'
ALTER TABLE [dbo].[PlanItems]
ADD CONSTRAINT [PK_PlanItems]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Plan1186'
ALTER TABLE [dbo].[Plan1186]
ADD CONSTRAINT [PK_Plan1186]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'AppUsers'
ALTER TABLE [dbo].[AppUsers]
ADD CONSTRAINT [PK_AppUsers]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'AboutContents'
ALTER TABLE [dbo].[AboutContents]
ADD CONSTRAINT [PK_AboutContents]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'OtherPlans'
ALTER TABLE [dbo].[OtherPlans]
ADD CONSTRAINT [PK_OtherPlans]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Counties'
ALTER TABLE [dbo].[Counties]
ADD CONSTRAINT [PK_Counties]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Surveyors'
ALTER TABLE [dbo].[Surveyors]
ADD CONSTRAINT [PK_Surveyors]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'BookPlans'
ALTER TABLE [dbo].[BookPlans]
ADD CONSTRAINT [PK_BookPlans]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------